<?php
header('content-type:text/html;charset=utf-8;');

$conn = mysqli_connect('localhost','root','root','zhangsan_game');
$name = $_POST['un'];
$pw = $_POST['pw'];
$day = $_POST['day'];

$sql = "SELECT*FROM `yhxx` WHERE `username`='$name' AND `password`='$pw'";
$res = mysqli_query($conn,$sql);//操作的数据库 查 $conn数据库
$row = mysqli_fetch_assoc($res);//解析的结果
if($row){
    echo 1;
    if($day==1){
        setcookie('name',$name,time()+7*24*60*60,'/');
    }else{
        setcookie('name',$name,time()+60,'/'); 
    }
}else{
    echo 0; 
}
?>